<template>
  <view class="upload-wrapper">
    <web-view :src="'http://iotplat.yunzhen.tech:8080/runde/#/?helmetusername='+helmetusername+'&helmetpassword='+helmetpassword" @message="handleExit" @onPostMessage="handleExit"></web-view>
  </view>
</template>

<script>
import { userProfileget,dataQuery  } from "@/api/index.js";

export default {
  data() {
    return {
      helmetusername:'',
      helmetpassword:'',
      timer:null
    };
  },
  onLoad(){
  },
  onHide() {
      clearInterval(this.timer);
      this.timer = null;
  },
  onShow() {
    this.getList();
    let roleKey = uni.getStorageSync("roleKey");
    if(roleKey=='Inspector'){
        this.timer = setInterval(function() {
      const code = "alarm_summary";
      let number = 0;
      dataQuery({}, code).then(res => {
        res.forEach(item => {
          if (item.label === "notRecovered") {
            if (item.value) {
                uni.showTabBarRedDot({
	                index: 1
                })
            } else {
                uni.removeTabBarBadge({
		             index:1
              })
            }
          }else {
              uni.removeTabBarBadge({
		             index:1
              })
          }
        });
        // // 赋值给报警列表铃铛的角标
        // i[0].setAttribute("badge-text", number);
      });
    }, 5000);
    }else {

    }
   
  },
   watch: {
    "helmetusername"(val) {
      // location.reload()
      // this.adminInfo = val;
      // this.UA();
    }
  },
  methods: {
    getList() {
      userProfileget().then(res => {
        this.userId = res.data.userId;
        let username = this.userId + "helmetusername";
        let userpassword = this.userId + "helmetpassword";
        this.helmetusername = uni.getStorageSync(username);
        this.helmetpassword = uni.getStorageSync(userpassword);
      });
    }
  }
};
</script>

<style lang="scss">
</style>
